<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--导入easyui样式 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/icon.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>查看车辆位置</title>
</head>
<script type="text/javascript">
$(function () {
	$("#dg").datagrid({
		url:'selectCar1',
		columns:[[   
		          {field:'ck',checkbox:true},
		          {field:'cid',title:'编号',width:100},    
		          {field:'plate',title:'车牌号',width:100},    
		          {field:'volume',title:'体积',width:100},    
		          {field:'weight',title:'重量',width:100},    
		          {field:'purchasing',title:'购买日期',width:100},    
		          {field:'state',title:'状态',width:100},    
		          {field:'driver',title:'司机',width:100},
		          {field:'position',title:'车辆位置',width:100},
		      ]],
		      rownumbers:true,
		      pagination:true,
		      pagePosition:'bottom',
		      pageSize:3,
		      pageList:[2,3,4],	
		      toolbar: [{
			  		iconCls: 'icon-edit',
			  		text:'车辆定位',
			  		handler: function(){
			  			var  stus= $('#dg').datagrid('getSelections');
			  			if(stus.length!=1){
			  				$.messager.alert('信息','请选择一条数据','info');	
		  					$('#dg').datagrid('load');
			  			}else{
			  				$("#updateCarposition").dialog("open").dialog('setTitle', '更新车辆位置');
			  				$('#ss1').combobox({    
			  				  	url:'selectPosition',    
			  				  	valueField:'id',    
			  				  	textField:'text'   
			  				  	});
			  				$('#cc1').combobox({    
				  			  	url:'selectState',    
				  			  	valueField:'id',    
				  			  	textField:'text'   
				  			  	});
			  				$('#ck').val(stus[0].cid);
			  				$('#ss1').combobox('setValue', stus[0].position);
			  				$('#cc1').combobox('setValue', stus[0].state);
			  				$('#cancl1').linkbutton({
			  					onClick:function(){
			  						$("#update").form('clear');  						
		  							$("#updateCarposition").dialog("close");
		  							 $('#dg').datagrid('load');
			  					}
			  				})
			  				$("#save2").linkbutton({
			  					onClick:function(){
			  						var cid=$("#ck").val();	 						
			  						var position =$("#ss1").combobox('getText');		  				
			  						var state =$("#cc1").combobox('getText');			  					
				  					$.ajax({
				  						url:'updateCarPosition',
				  						type:'post',
				  					data:
				  					{'position':position,'state':state,'cid':cid},
				  					dataType:'text',
				  					success:function(yy){
				  						if(yy==1){
				  							$.messager.alert('信息','修改成功','info');
				  							$("#update").form('clear');  						
				  							$("#updateCarposition").dialog("close");
				  							 $('#dg').datagrid('load');
				  						}
				  					}
				  					})
			  					}
			  				})
			  			}
			  		}		  	
			  	}]
	})
})
</script>
<body>
<table id="dg"></table>
<!--修改彈出窗口 -->
<div id="updateCarposition" class="easyui-dialog"  closed="true" buttons="#dlg2-buttons" style="width: 300px;height: 300px" >
<br>
<form id="update">
<div style="margin-top:10px;text-align: center;">
<input id="ck"name="cid" type="text" style="display:none"><br><br>
车辆位置<input id="ss1" name="position" value="" editable="false"><br><br>
车辆状态<input id="cc1"name="state"  value=""editable="false"><br><br>

</div>
</form>
<div id="dlg1-buttons" style="margin-top:10px;text-align: center;" >
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button id="save2"  class="easyui-linkbutton"  iconcls="icon-save">确定</button>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="cancl1" class="easyui-linkbutton" onclick="javascript:$('#updateCarposition').dialog('close')" iconcls="icon-cancel">取消</a>
</div>
</div>
</body>
</html>